1d2bac
@@ -22,6 +22,7 @@
 package org.jboss.as.security.vault;
 
 import java.io.Console;
+import java.util.InputMismatchException;
 import java.util.Scanner;
 
 import org.apache.commons.cli.CommandLine;
@@ -102,25 +103,27 @@
public class VaultTool {
             Scanner in = new Scanner(System.in);
             while (true) {
                 System.out.println(VaultMessages.MESSAGES.interactiveCommandString());
-                int choice = in.nextInt();
-                switch (choice) {
-                    case 0:
-                        System.out.println(VaultMessages.MESSAGES.startingInteractiveSession());
-                        VaultInteractiveSession vsession = new VaultInteractiveSession();
-                        tool.setSession(vsession);
-                        vsession.start();
-                        break;
-                    case 1:
-                        System.out.println(VaultMessages.MESSAGES.removingInteractiveSession());
-                        tool.setSession(null);
-                        break;
-                    default:
-                        System.exit(0);
+                try {
+                    int choice = in.nextInt();
+                    switch (choice) {
+                        case 0:
+                            System.out.println(VaultMessages.MESSAGES.startingInteractiveSession());
+                            VaultInteractiveSession vsession = new VaultInteractiveSession();
+                            tool.setSession(vsession);
+                            vsession.start();
+                            break;
+                        case 1:
+                            System.out.println(VaultMessages.MESSAGES.removingInteractiveSession());
+                            tool.setSession(null);
+                            break;
+                        default:
+                            System.exit(0);
+                    }
+                } catch (InputMismatchException e) {
+                    System.exit(0);
                 }
             }
-
         }
-
     }
 
     public VaultTool(String[] args) {
